var express = require('express');
var router = express.Router();
const { get, add, remove, update,getOne } = require("../service/supGoodsService")

router.get('/', async function (req, res, next) {
    const data = await get();
    res.send(data);
});
router.get('/:_id', async function (req, res, next) {
    const { _id } = req.params;
    const data = await getOne(_id);
    res.send(data);
});

router.post('/', async function (req, res, next) {
    const parameter = req.body;
    const data = await add(parameter)
    res.send(data)
});

router.delete('/:_id', async function (req, res, next) {
    const { _id } = req.params;
    const data = await remove(_id)
    res.send(data)
});

router.patch('/:_id', async function (req, res, next) {
    const { _id } = req.params;
    const parameter = req.body;
    const data = await update(_id, parameter);
    res.send(data)
});

module.exports = router;
